package com.visionvera.retrofitservice.net;

import android.content.Context;

/**
 * Created by dongyukun on 2017/11/9.
 * RetrofitUtils初始化相关
 */

public class RetrofitUtils {
    public static final String TAG = "RetrofitAPI";
    private static Context context;
    private static Object object;

    private RetrofitUtils() {
        throw new UnsupportedOperationException("u can't instantiate me...");
    }

//    /**
//     * 初始化工具类
//     *
//     * @param context 上下文
//     */
//    public static void init(Context context) {
//        RetrofitUtils.context = context.getApplicationContext();
//    }

    /**
     * 初始化工具类
     *
     * @param context 上下文
     */
    public static <V> void init(Context context, Class<V> clazz) {
        RetrofitUtils.context = context.getApplicationContext();
        RetrofitFactory.getInstance().createAPI(clazz);
    }



    /**
     * 获取ApplicationContext
     *
     * @return ApplicationContext
     */
    public static Context getContext() {
        if (context != null) return context;
        throw new NullPointerException("u should init first");
    }
}
